package com.iotechn.unimall.data.dto.excel;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
import lombok.Data;

import java.io.Serializable;
import java.text.DecimalFormat;

/**
 * @author kyms
 * @date 2020-06-04 16:46
 */
@ExcelTarget("orderSkuSummaryExcelEntity")
@Data
public class OrderSkuSummaryDTO implements Serializable {

    private Long skuId;
    @Excel(name = "条码", width = 15d)
    private String barCode;
    @Excel(name = "商品名称", width = 15d)
    private String spuTitle;
    @Excel(name = "规格", width = 15d)
    private String skuTitle;
    @Excel(name = "单位")
    private String unit;
    @Excel(name = "销售总额", isStatistics = true)
    private Float price;
    @Excel(name = "销售总数", isStatistics = true)
    private Float num;
    @Excel(name = "退款总额", isStatistics = true)
    private Float refundPrice;
    @Excel(name = "退款总数", isStatistics = true)
    private Float refundNum;

    @Excel(name = "数量小计", isStatistics = true)
    private Float summaryTotalNum;
    @Excel(name = "总额小计", isStatistics = true)
    private Float summaryPrice;

    public Float getSummaryTotalNum() {
        if (this.num == null || this.refundNum == null) {
            return 0F;
        }
        DecimalFormat decimalFormat = new DecimalFormat(".00");
        String total = decimalFormat.format(this.num - this.refundNum);
        return Float.valueOf(total);
    }

    public Float getSummaryPrice() {
        if (this.price == null || this.refundPrice == null) {
            return 0F;
        }
        DecimalFormat decimalFormat = new DecimalFormat(".00");
        String total = decimalFormat.format(this.price - this.refundPrice);
        return Float.valueOf(total);
    }
}
